<template>
	<view class="content" :style="{ height: windowHeight + 'px' }">
		<view class="achievement-list">
			<view class="achievement-item first">
				<view class="title">慧眼如炬</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819941042.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.correctWrongNum) }}</view>
					<view class="desc">对题库错误内容进行纠错</view>
					<view class="grey">你已纠错{{achievements.correctWrongNum}}题啦，加油</view>
				</view>
			</view>

			<view class="achievement-item">
				<view class="title">见多识广</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819948323.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.addQuestionNum) }}</view>
					<view class="desc">上传科普知识题库获取认可</view>
					<view class="grey">你已上传{{achievements.addQuestionNum}}题啦，加油</view>
				</view>
			</view>

			<view class="achievement-item">
				<view class="title">学有所成</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819948330.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.level) }}</view>
					<view class="desc">答题升级成功</view>
					<view class="grey">你已经在第{{achievements.level}}级啦，加油</view>
				</view>
			</view>

			<view class="achievement-item">
				<view class="title">出类拔萃</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819948337.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.joinedCompetitionNum) }}</view>
					<view class="desc">竞赛答题取得优秀名次</view>
					<view class="grey">你已经竞赛答题{{achievements.joinedCompetitionNum}}次，加油</view>
				</view>
			</view>

			<view class="achievement-item">
				<view class="title">笃志好学</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819948341.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.practiceDays) }}</view>
					<view class="desc">累计打卡练习天数</view>
					<view class="grey">你已经打卡练习{{achievements.practiceDays}}天，恭喜过关</view>
				</view>
			</view>

			<view class="achievement-item">
				<view class="title">格物致远</view>
				<image
					src="https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/4/28/1745819948348.png?x-oss-process=image/resize,w_300"
					class="whale-icon"></image>
				<view class="item-content">
					<view class="count">{{ computeds(achievements.watchPopularizeNum) }}</view>
					<view class="desc">观看前沿科学知识科普学习视频</view>
					<view class="grey">你已经观看{{achievements.watchPopularizeNum}}个视频啦，恭喜过关</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		systemInfo
	} from '../../utils/mixin'
	import {
		myLight
	} from '@/api/index'
	export default {
		components: {},
		mixins: [systemInfo],
		data() {
			return {
				achievements: {}
			}
		},
		onLoad() {
			this.getSystemInfo();
			this.getDetail()
		},
		methods: {
			async getDetail() {
				const res = await myLight({})
				this.achievements = res.data
			},
			computeds(item) {
				if (item <= 10) {
					return item + '+'
				} else if (item > 10) {
					// 将数字向下取整到最近的10的倍数
					const rounded = Math.floor(item / 10) * 10;
					return rounded + '+';
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		background-color: #f5f5f5;
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx 40rpx;
	}

	.first {
		margin-top: 20px !important;
	}

	.achievement-list {
		background-color: #fff;
		border-radius: 5px;
		height: 100%;
		width: 100%;
		overflow: auto;

		.achievement-item {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 32rpx;
			margin-bottom: 40rpx;
			display: flex;
			align-items: center;
			border: 1px solid #eee;
			width: calc(100% - 104rpx);
			margin-left: 20rpx;
			position: relative;
			z-index: 1;

			.title {
				font-size: 30rpx;
				color: #333;
				font-weight: 500;
				position: absolute;
				width: 100px;
				text-align: center;
				left: 0;
				top: -10px;
				z-index: 9;
			}

			.whale-icon {
				width: 74px;
				height: 60px;
				margin-right: 24rpx;
			}

			.item-content {
				flex: 1;
				text-align: center;

				.count {
					font-size: 44rpx;
					font-weight: 600;
					margin-bottom: 10rpx;
					line-height: 1;
				}

				.desc {}

				.grey {
					font-size: 22rpx;
					color: #666;
					line-height: 1.2;
				}
			}

			&:nth-child(1) .count {
				color: #3B82F6;
			}

			&:nth-child(2) .count {
				color: #F59E0B;
			}

			&:nth-child(3) .count {
				color: #EC4899;
			}

			&:nth-child(4) .count {
				color: #38BDF8;
			}

			&:nth-child(5) .count {
				color: #4F46E5;
			}

			&:nth-child(6) .count {
				color: #22C55E;
			}
		}
	}
</style>